/*     */ package com.hs.activation.common.utils;
/*     */ 
/*     */ import com.alibaba.fastjson.JSONObject;
import org.springframework.web.client.RestTemplate;

import java.io.BufferedReader;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStreamReader;
/*     */ import java.io.PrintWriter;
/*     */ import java.net.URL;
/*     */ import java.net.URLConnection;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ public class WebUtils
/*     */ {
/*     */   public static String sendGet(String url, String param) {
    RestTemplate restTemplate = new RestTemplate();
    BufferedReader in = null;
    try {
        String urlNameString = url + "?" + param;
        String response = restTemplate.getForObject(urlNameString, String.class);
        JSONObject result = JSONObject.parseObject(response);
        return (String) result.get("openid");
        /*  31 */
        /*     */
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   
/*     */   public static String sendPost(String url, String param) {
/*  79 */     PrintWriter out = null;
/*  80 */     BufferedReader in = null;
/*  81 */     String result = "";
/*     */     try {
/*  83 */       URL realUrl = new URL(url);
/*     */       
/*  85 */       URLConnection conn = realUrl.openConnection();
/*     */       
/*  87 */       conn.setRequestProperty("accept", "*/*");
/*  88 */       conn.setRequestProperty("connection", "Keep-Alive");
/*  89 */       conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
/*     */ 
/*     */       
/*  92 */       conn.setDoOutput(true);
/*  93 */       conn.setDoInput(true);
/*     */       
/*  95 */       out = new PrintWriter(conn.getOutputStream());
/*     */       
/*  97 */       out.print(param);
/*     */       
/*  99 */       out.flush();
/*     */ 
/*     */       
/* 102 */       in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
/*     */       String line;
/* 104 */       while ((line = in.readLine()) != null) {
/* 105 */         result = result + result;
/*     */       }
/* 107 */     } catch (Exception e) {
/* 108 */       System.out.println("发送 POST 请求出现异常！" + e);
/* 109 */       e.printStackTrace();
/*     */     } finally {
/*     */ 
/*     */       
/*     */       try {
/* 114 */         if (out != null) {
/* 115 */           out.close();
/*     */         }
/* 117 */         if (in != null) {
/* 118 */           in.close();
/*     */         }
/* 120 */       } catch (IOException ex) {
/* 121 */         ex.printStackTrace();
/*     */       } 
/*     */     } 
/* 124 */     return result;
/*     */   }
/*     */ }


/* Location:              C:\Users\yzc\Desktop\新建文件夹 (3)\activation-0.0.16.jar!\BOOT-INF\classes\com\hs\activation\commo\\utils\WebUtils.class
 * Java compiler version: 16 (60.0)
 * JD-Core Version:       1.1.3
 */